package com.dbgs.qqui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.qmuiteam.qmui.widget.QMUICollapsingTopBarLayout;
import com.qmuiteam.qmui.widget.QMUITopBar;

import java.util.ArrayList;
import java.util.List;

public class CollapsingTopBarLayoutActivity extends AppCompatActivity {
    MessagesAdapter messagesAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.collapsingtopbarlayout);
        QMUIStatusBarHelper.translucent(this);
        RecyclerView recyclerView = findViewById(R.id.recyclerView);

        LinearLayoutManager mPagerLayoutManager;
        mPagerLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(mPagerLayoutManager);
//        SpaceDecoration spaceDecoration = new SpaceDecoration(true,100);
//        rcv.addItemDecoration(spaceDecoration);
        recyclerView.setHasFixedSize(true);
        if (messagesAdapter == null){
            messagesAdapter = new MessagesAdapter();
        }
        List<String > list = new ArrayList<>();
        for (int i=0;i<50;i++){
            list.add(String .valueOf(i));
        }
        messagesAdapter.addData(list);
        recyclerView.setAdapter(messagesAdapter);
        messagesAdapter.bindToRecyclerView(recyclerView);


        messagesAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);
//        messagesAdapter.isFirstOnly(false);  //动画默认只执行一次,如果想重复执行可设置
        messagesAdapter.disableLoadMoreIfNotFullPage();//默认第一次加载会进入回调，如果不需要可以配置：

        QMUICollapsingTopBarLayout collapsing_topbar_layout =findViewById(R.id.collapsing_topbar_layout);
        collapsing_topbar_layout.setTitle("商品详情");

        QMUITopBar topbar = findViewById(R.id.topbar);
        topbar.addLeftBackImageButton();



    }

}
